# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Brad Fanella <bradfanella@archlinux.us>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=libcss
pkgver=0.9.1
pkgrel=6
pkgdesc='CSS parser and selection engine'
arch=(loong64 x86_64)
url='https://www.netsurf-browser.org/projects/libcss/'
license=(MIT)
makedepends=(netsurf-buildsystem)
depends=('libparserutils>=0.2.4' 'libwapcaplet>=0.4.3')
source=("https://download.netsurf-browser.org/libs/releases/libcss-$pkgver-src.tar.gz")
b2sums=('32206403f77997e6692eed00c9233e6f49f08efc2515901a8bef7590883e44ef320511368fe5a67968102911d849696a4419735c7f6691f0f272fcc3b9a000d8')

prepare() {
  sed -i 's,_BSD_SOURCE,_DEFAULT_SOURCE,' $pkgname-$pkgver/Makefile
}

build() {
  export CFLAGS="$CFLAGS -shared -fPIC -w"
  export LDFLAGS="$LDFLAGS -shared -z,now"
  make -C $pkgname-$pkgver \
    COMPONENT_TYPE=lib-shared \
    INCLUDEDIR=include \
    LIBDIR=lib \
    PREFIX=/usr
}

package() {
  make -C $pkgname-$pkgver \
    COMPONENT_TYPE=lib-shared \
    DESTDIR="$pkgdir" \
    INCLUDEDIR=include \
    LIBDIR=lib \
    PREFIX=/usr \
    install
  install -Dm644 $pkgname-$pkgver/COPYING \
    "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
